package com.sofly.controller.group3;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sofly.entity.DataGrid;
import com.sofly.entity.StockManage;
import com.sofly.service.group3.IStockManageService;

/**
 * 
* <p>Title:StockManageController </p>
* <p>Description: </p>
* <p>Company: </p> 
* @author SuYan
* @date 下午3:39:55
 */
@Controller
public class StockManageController {
	
	
	 
	@Autowired
	private IStockManageService stockManageService;
	/**
	 * 查询库存信息列表
	 * @param page
	 * @param rows
	 * @param saveDate
	 * @return
	 */
	@RequestMapping(value="/href/getStockManageList")
	@ResponseBody
	public DataGrid getStockManageList(String page,String rows,String saveDate){
		DataGrid dataGrid = new DataGrid();
		int page1 = Integer.parseInt(page);
		int size1 = Integer.parseInt(rows);
		List<StockManage> list = stockManageService.getStockManageList((page1-1)*size1, size1);
		int total = stockManageService.getCount();
		dataGrid.setRows(list);
		dataGrid.setTotal(total);
		return dataGrid;
		
	}
	/**
	 * 
	 * @param stockManage
	 * @return
	 */
	@RequestMapping("/href/addStockManage")
	@ResponseBody
	public int addStockManage(StockManage stockManage){
		int i  = stockManageService.addStock(stockManage);
		return  i;
	} 
	/**
	 * 
	 * @param productId
	 * @return
	 */
	@RequestMapping("/href/SearchStockManage")
	@ResponseBody
	public StockManage getStockManage(String productId){
		StockManage stockManage = stockManageService.getStockById(productId);
		
		return stockManage;
	}
}
